#include <iostream>

using namespace std;


int main()
{
    int* p = new int;
    cout << p << endl;
    cout << *p << endl;

    *p = 1024;

    cout << *p << endl;


    delete p;

    int len = 5;

    // cout << "input len: "<< endl;
    // cin >> len;

    int* pa = new int[len];

    int value = 2;

    int * iter = pa;
   while ( iter < (pa + len))
   {
        *iter = value * value;
        value ++;
        iter ++;
   }
    
    for (int i = 0; i < len; i ++)
    {
       cout << *(pa + i) << endl; 
    }
    cout << "------------------" << endl;

    for (int * pi = pa; pi < pa +len; pi ++)
    {
        cout << *pi << ", ";
    }
    cout << "\n------------------" << endl;
    cout << "------------------" << endl;

    for (int i=0; i < len; i ++)
    {
        cout << pa[i] << ", ";
    }
    cout << "\n------------------" << endl;

    cout << "pa = " << pa << endl;
    cout << "*pa = " << *pa << endl;
    cout << "pa[0] = " << pa[0] << endl;
    cout << "&pa[0] = " << &pa[0] << endl;

    cout << "sizeof(pa) = " << sizeof(pa) << endl;
    cout << "sizeof(&pa[0]) = " << sizeof(&pa[0]) << endl;

    delete [] pa;

    int arr[4] = {1, 2, 3, 4};
    int *ap = arr;
    cout << "arr = "  << arr << endl;
    cout << "ap = " << ap << endl;
    cout << "sizeof(arr) = " << sizeof(arr) << endl;
    cout << "sizeof(ap) = " << sizeof(ap) << endl;
}